<template>
	<view>
		<scroll-view :scroll-x="false" :scroll-y="true" class="scroll-container" :style="'height:'+windowHeight+'px;'">
			<view>
				 <u-swiper :list="bannerList" mode="none"  :height="450"  :duration="1000"></u-swiper>
			</view>
			<view class="u-border-bottom">
				<u-notice-bar color="#F29100" :volume-size="34" type="none" :font-size="30"  mode="horizontal" :list="noticebarList" padding="24rpx 24rpx"></u-notice-bar>
			</view>
			<u-gap height="10" bg-color="#ffffff"></u-gap>
			<view class="u-p-20">
				<u-row>
					<u-col :span="7">
						<view class="u-flex u-row-left u-col-center">
							<view>
								<u-avatar mode="square" :src="vuex_userInfo.avatar"></u-avatar>
							</view>
							<view style="margin-left: 20rpx;height: 100rpx;display: flex;flex-direction: column;justify-content: space-between;align-items: left;">
								<view style="font-size: 30rpx;">{{vuex_userInfo.userName}}</view>
								<u-tag v-if="vuex_userInfo.vipLevel==1" text="普通会员" mode="light" shape="circle"   type="warning"/>
								<u-tag v-if="vuex_userInfo.vipLevel==2" text="钻石会员" mode="dark" shape="circle"   type="warning"/>
							</view>
						</view>
					</u-col>
					
					<u-col :span="5">
						<view class="u-flex u-row-between u-col-center" style="height: 100rpx;text-align: center;">
								<view>
									<view>{{vuex_userInfo.accountBalance}}</view>
									<view>余额</view>
								</view>
								<view>
									<view>{{vuex_userInfo.integralBalance}}</view>
									<view>积分</view>
								</view>
								<view>
									<view>{{vuex_userInfo.couponsCount}}</view>
									<view>优惠券</view>
								</view>
						</view>
					</u-col>
				</u-row>
			</view>
			<u-gap height="10" bg-color="#ffffff"></u-gap>
			<view class="u-p-20">
				<u-row>
					<u-col :span="6">
						<view  @click="switchToShopCar()" style="display: flex;flex-direction: column;justify-content: center;align-items: center;">
							<view style="width: 128prx;height: 128rpx;" class="u-flex u-row-center u-col-center">
								<u-image src="/static/images/home/way-0.png" width="98" height="98"></u-image>
							</view>
							<view class="u-m-t-20" style="text-align: center;">
								<view style="font-size: 36rpx;font-weight: bold;">门店自取</view>
								<view style="font-size: 28rpx;color: #909399;margin-top: 16rpx;">预约点单,到店自取</view>
							</view>
						</view>
					</u-col>
					<u-col :span="6">
						<view @click="toMyAddress()" style="display: flex;flex-direction: column;justify-content: center;align-items: center;">
							<view>
								<u-image src="/static/images/home/way-1.png" width="128" height="128"></u-image>
							</view>
							<view class="u-m-t-20" style="text-align: center;">
								<view style="font-size: 36rpx;font-weight: bold;">配送上门</view>
								<view style="font-size: 28rpx;color: #909399;margin-top: 16rpx;">外卖下单,快速到达</view>
							</view>
						</view>
					</u-col>
				</u-row>
			</view>
			<template v-if="goodList.length>0">
				<u-gap height="10" bg-color="#ffffff"></u-gap>
				<view  class="u-p-30  u-flex u-row-between u-col-center">
					<view class="u-flex u-row-left u-col-center">
						<view class="u-m-r-20 u-p-t-5">
							<u-icon name="thumb-up-fill"   color="#F29100"  size="48"></u-icon>
						</view>
						<view class="title"><text style="font-size: 36rpx;font-weight: bold;">今日现货</text></view>
					</view>
					<view class="u-m-t-5">
						<u-tag text="更多" mode="light" shape="circle" type="warning" @click="switchToShopCar(0)"/>
					</view>
				</view>
				<view class="">
					<u-row>
						<u-col :span="6" v-for="(good,index) in goodList" :key="index">
							<view class="good-item" @click="toGoodDetail(good)">
								<view class="u-flex u-row-center u-col-center u-m-t-20">
									<u-image :src="good.url" width="320rpx" height="320rpx">
										<u-loading slot="loading"></u-loading>
									</u-image>
								</view>
								<view class="u-line-2" style="width: 100%; font-size: 32rpx;max-height: 100rpx;margin: 20rpx;">
									{{good.goodName}}
								</view>
								
								<view style="color: #909399;margin: 20rpx;">
									<text style="color: #f29100;font-size: 32rpx;font-weight: bold;">¥{{good.price}}</text>
									<!-- <text style="margin: 0rpx 10rpx;">{{good.priceUnit}}</text> -->
								</view>
							</view>
						</u-col>
					</u-row>
				</view>
			</template>
		</scroll-view>
	</view>
</template>

<script>
	const multipartUrl="http://175.24.203.136:8081/tj-chat/fileServer/getFileFromParam?filePath=tiannuo/images/";
	import themeGird from '@/components/gird/theme-gird.vue';
	import {indexGoodList} from "@/util/data/goodList.js"; 
	export default {
		components:{
			themeGird
		},
		data() {
			return {
				windowHeight:uni.getSystemInfoSync().windowHeight,
				bannerList:[],
				noticebarList:[
					'生日蛋糕请提请预定',
					'当天预定有可能来不及的哦!'
				],
				goodList: [],
			};
		},
		onLoad:function(){
			this.getBannerList();
			this.getRecommendGoodList();	
		},
		methods:{
			//获取轮播图
			getBannerList:function(){
				this.bannerList=[
					{
						image: multipartUrl+'banner/banner1.jpg',
						title: '1'
					},
					{
						image: multipartUrl+'banner/banner2.jpg',
						title: '2'
					},
				]	
			},
			//跳转到购物车点单界面
			switchToShopCar:function(position){
				this.$u.route({
					type:'tab',
					url:'/pages/tabbar/shopCar/shopCar',
					params:{
						position:position?position:'',
					}
				})
			},
			//跳转我的地址界面
			toMyAddress:function(){
				this.$u.route({
					url:'/pages/common/my-address/my-address',
				})
			},
			
			//获取首页推荐的商品列表
			getRecommendGoodList:function(){
				this.goodList=indexGoodList;
			},
			//跳转商品详情
			toGoodDetail: function(goodDetail) {
				this.$u.route({
					url:'/pages/common/good/good-detail/good-detail',
					params:{
						skuId:goodDetail.skuId,
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.scroll-container{
		::-webkit-scrollbar{
			display: none;
			width: 0;
			height: 0;
		}
	}
	.good-item {
		width: 100%;
		border: 1px solid #ffffff;
		margin-bottom: 20rpx;
		border-radius: 10rpx;
		background-color: #ffffff;
	}
</style>

